package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.core.tool.FormatUtil;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.*;
import com.ymttest.utils.YMTDateUtil;

public class EmailWapper {
	SqlManager manage;

	public EmailWapper() {
		manage = new SqlManager("Email");
	}

	public List<MailRecord> selectMailRecordByBatchid(String batchid){
		Map m=new HashMap<>();
		m.put("batchid", batchid);
		List<MailRecord> list = manage.getSelectResults(
				"com.ymttest.database.mapping.MailMapper.selectMailRecordByBatchid", m);
		manage.commit();
		return list;
	}
	public List<MailRecord> selectMailRecordById(String id){
		Map m=new HashMap<>();
		m.put("id", id);
		List<MailRecord> list = manage.getSelectResults(
				"com.ymttest.database.mapping.MailMapper.selectMailRecordById", m);
		manage.commit();
		return list;
	}
	public List<MailRecord> selectMailRecordByToMail(String tomail){
		Map m=new HashMap<>();
		m.put("tomail", tomail);
		List<MailRecord> list = manage.getSelectResults(
				"com.ymttest.database.mapping.MailMapper.selectMailRecordByToMail", m);
		manage.commit();
		return list;
	}
	public List<MailContent> selectMailContentById(String id){
		Map m=new HashMap<>();
		m.put("id", id);
		List<MailContent> list = manage.getSelectResults(
				"com.ymttest.database.mapping.MailMapper.selectMailContentById", m);
		manage.commit();
		return list;
	}
	
	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manage.close();
	}

	@Override
	protected void finalize() throws Throwable {
		this.close();
		manage = null;
		super.finalize();
	}

	
	public static void main(String[] args) {
		System.out.println(FormatUtil.beanToGSONString(new EmailWapper().selectMailContentById("e209fb03ee3c45d58d9c803154c4df36")));
	}

	
}
